<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/c" prefix="c" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net/el"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="com.solution.webconstant.PermissionConstants" %>

<%
	HashMap permissionMap = ((HashMap)(session.getAttribute("userPermissionsInfo")));
%>
<script language="JavaScript" src="js/Calendar.js" type="text/JavaScript"></script>
<script language="JavaScript">
function fnSearch()
{
	document.categoryForm.action='/searchCategory.do?';
	document.categoryForm.submit();
}
function fnEditViewCategoryDetails(category_id_value, screen_type_value){
	document.categoryForm.screen_type.value=screen_type_value;
	document.categoryForm.category_id.value=category_id_value;
	document.categoryForm.action='/editViewCategory.do?';
	document.categoryForm.submit();
}
function clearForm(formObj){
	var elements = formObj.elements;
	for(i=0; i<elements.length; i++){
		if(elements[i].type == "text")
			elements[i].value = "";
		if(elements[i].type == "select-one" || elements[i].type == "select-multiple")
			elements[i].selectedIndex = 0;
	}
}
</script>
<html:form action="/searchCategory">
	<html:hidden property="show_list" />
	<html:hidden property="screen_type" />
	<html:hidden property="category_id" />
	<%String linktab = (String)request.getAttribute("selectedTab"); %>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td>
	    	<table width="700px" border="0" cellspacing="0" cellpadding="0">
	  			<tr>
					<%if("CREATE".equalsIgnoreCase(linktab)) {%>
				    <td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("createLink")%>">Create</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else {%>
					<td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("createLink")%>">Create</a></div></td>
				    <td class="inactiveTabc2"></td>
					<%}%>
				    <td class="spacer"></td>
					<%if("EDIT".equalsIgnoreCase(linktab)) {%>
					<td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("editLink")%>">Edit</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else{%>
				    <td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("editLink")%>">Edit</a></div></td>
				    <td class="inactiveTabc2"></td>
					<%}%>
				    <td class="spacer"></td>
					<%if("VIEW".equalsIgnoreCase(linktab)) {%>
					<td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("viewLink")%>">View</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else{%>
				    <td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("viewLink")%>">View</a></div></td>
				    <td class="inactiveTabc2"></td> 
					<%}%>
	  			</tr>
			</table>
		</td>
  	</tr>
  	<tr>
    	<td class="formbg" valign="top">
    		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  				<tr>
    				<td>
    					<table width="100%" border="0" cellspacing="4" cellpadding="0">
							<tr>
								<td>&nbsp;</td>	
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td colspan="6"><jsp:include page="showErrorMessage.jsp"/></td>
							</tr>
	  						<tr>
								<td>&nbsp;</td>
								<td class="formText">Name</td>
								<td valign="middle"><html:text property="category_name" styleId="category_name" styleClass="form1" maxlength="20"/>
								</td>
								<td class="formText">Description</td>
								<td valign="middle"><html:textarea property="category_description" styleId="category_description" styleClass="textAreaForm" rows="2"/>
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td class="formText">Status</td>
								<td colspan="4">
									<html:select styleClass="form2" styleId="category_status" property="category_status">
										<html:option value="">--Please Select--</html:option>
										<html:option value="2">Active</html:option>
										<html:option value="3">InActive</html:option>
									</html:select>
								</td>
								<td colspan="3">&nbsp;</td>
							</tr>
							<tr>
								<td height="25" colspan="6" align="center" valign="top" >&nbsp;</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
		       	 				<td height="25" colspan="4" align="center" valign="top">
		       	 					<input type="button" class="imageButton" value="Search" onClick="JavaScript:fnSearch()">
		       	 					<input type="button" class="imageButton" value="Reset" onClick="JavaScript:clearForm(this.form)">
		       	 				</td>
								<td>&nbsp;</td>
		      				</tr>
		      				<tr>
								<td height="25" colspan="6" align="center" valign="top" >&nbsp;</td>
							</tr>
							<tr>
								<td  colspan="6">
									<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
										<logic:equal name="categoryForm" property="show_list" value="Y">
										<tr>
											<td>
												<display:table name="categoryForm.category_list" decorator="com.solution.decorator.CategoryDecorator"
													export="false"	requestURI="/searchCategory.do" cellspacing="0" cellpadding="0"
													pagesize="10" class="results" id="category">
													<display:column property="id" title="Code" />
													<display:column property="name" title="Name" />
													<logic:present property="status" name="category">
													<bean:define id="displayStatus" property="status" name="category"/>
													<display:column title="Status"><bean:message key="<%="Status."+displayStatus%>"/></display:column>
													</logic:present>
													<logic:equal name="categoryForm" property="screen_type" value="Edit">
														<display:column property="actionEdit" title="Action" />
													</logic:equal>
													<logic:equal name="categoryForm" property="screen_type" value="View">
														<display:column property="actionView" title="Action" />
													</logic:equal>
													<display:setProperty name="basic.msg.empty_list">&nbsp;</display:setProperty> 
												</display:table>
											</td>
					            		</tr>
					            		</logic:equal>
					          		</table>
					          	</td>
							</tr>
      					</table>
      				</td>
      			</tr>
      		</table>
      	</td>
	</tr>
	</table>  				
</html:form>